#include <iostream>
#include <string>
using namespace std;
class Sales_data{
friend Sales_data operator+(const Sales_data&,const Sales_data&);
friend istream &operator>>(istream&,Sales_data&);
friend ostream &operator<<(ostream&,const Sales_data&);
friend bool operator==(const Sales_data &lhs,const Sales_data &rhs);
friend bool operator!=(const Sales_data &lhs,const Sales_data &rhs);
private:
	string bookNo;
	unsigned units_sold;
	double revenue;
	double avg_price() const{return units_sold?revenue/units_sold:0.0;}
public:
	Sales_data(const string &s,unsigned n,double p):bookNo(s),units_sold(n),revenue(p*n){}
	Sales_data():Sales_data("",0,0){}
	Sales_data(const string s):Sales_data(s,0,0){}
	Sales_data(istream &is):Sales_data(){is>>*this;}
	string isbn()const{return bookNo;}
	Sales_data& operator+=(const Sales_data&);
	
	
};
Sales_data operator+(const Sales_data&,const Sales_data&);
istream &operator>>(istream&,Sales_data&);
ostream &operator<<(ostream&,const Sales_data&);
bool operator==(const Sales_data &lhs,const Sales_data &rhs);
bool operator!=(const Sales_data &lhs,const Sales_data &rhs);
Sales_data& Sales_data::operator+=(const Sales_data &chs)
{
	units_sold+=chs.units_sold;
	revenue+=chs.revenue;
	return *this;
}
istream &operator>>(istream &is,Sales_data &item)
{
	double price=0;
	is>>item.bookNo>>item.units_sold>>price;
	if(is)
		item.revenue=price*item.units_sold;
	else
		item=Sales_data();
	return is;
}
ostream &operator<<(ostream &os,const Sales_data &item)
{
	os<<item.isbn()<<" "<<item.units_sold<<" "<<item.revenue<<" "<<item.avg_price();
	return os;
}
Sales_data operator+(const Sales_data &lhs,const Sales_data &rhs)
{
	Sales_data sum=lhs;
	sum+=rhs;
	return sum;
}
bool operator==(const Sales_data &lhs,const Sales_data &rhs)
{
	return lhs.isbn()==rhs.isbn() && lhs.units_sold==rhs.units_sold && lhs.revenue==rhs.revenue;
}
bool operator!=(const Sales_data &lhs,const Sales_data &rhs)
{
	return !(lhs==rhs);
}